

# 短信应用 SDK AppID
appid = 1400453119  # SDK AppID 以1400开头
# 短信应用 SDK AppKey
appkey = "1f159462fb46a47b8f6cee5657fec1a7"
# 需要发送短信的手机号码
ll=['18186104290','18374863411']
# 短信模板ID，需要在短信控制台中申请
template_id = 783815  # NOTE: 这里的模板 ID`7839`只是示例，真实的模板 ID 需要在短信控制台中申请
# 签名
sms_sign = "一只快乐的程序猿"  # NOTE: 签名参数使用的是`签名内容`，而不是`签名ID`。这里的签名"腾讯云"只是示例，真实的签名需要在短信控制台中申请

def get_code():
  import random
  s_code = ''
  for i in range(4):
    s_code += str(random.randint(0, 9))
  return s_code

from qcloudsms_py import SmsSingleSender
from qcloudsms_py.httpclient import HTTPError
ssender = SmsSingleSender(appid, appkey)
params = [get_code(),'3']  # 当模板没有参数时，`params = []`



try:
  # result = ssender.send_with_param(86, ll[0],template_id, params, sign=sms_sign, extend="", ext="")
  result = ssender.send_with_param(86, ll[1],template_id, params, sign=sms_sign, extend="", ext="")
  print(result)
  if result.get('result')==0:
      pass

except HTTPError as e:
  print(e)
except Exception as e:
  print(e)
